const { DictService } = require('../../services/admin');
// 字典控制器
const DictController = {
  // 字典新增
  add: async (req, res) => {
    const { name, label, value, description } = req.body;
    const result = await DictService.add({ name, label, value, description });
    res.send(result);
  },
  // 字典删除
  delete: async (req, res) => {
    const { _id } = req.body;
    const result = await DictService.delete(_id);
    res.send(result);
  },
  // 字典修改
  edit: async (req, res) => {
    const { _id, name, label, value, description } = req.body;
    const result = await DictService.edit(_id, { name, label, value, description });
    res.send(result);
  },
  // 字典列表
  list: async (req, res) => {
    const { name } = req.body;
    const result = await DictService.list(name);
    res.send(result);
  },
};

module.exports = DictController;
